import shutil, os, sys
from pathlib import Path
import datetime
import updateModelParamsUtils, MyUtils


def demo(publish,srcProductPath="product1/model", dstModelPathList=['product1/model', 'product2/model'],commitInfo="xxx",stepIdxListNot=[]):
    #rootPath = 'E:/workspace/0_model/0_shenzhenHuaxing_piantie-new/'
     modelName = srcProductPath.split('/')[-1]
     srcModelPath = srcProductPath
     if( not os.path.exists(srcModelPath)):
            print("srcModelPath path not exist: ", srcModelPath)
            exit(0)
     else:
         print(">>> src model: ", srcModelPath)
         print(">>>")

     dstModelPathList = dstModelPathList
    
    #矩形
     
     updateModelParamsUtils.modelUpdateDemo(commitInfo, srcModelPath,dstModelPathList,stepIdxListNot,publish)

def run():
    rootPath = 'E:\\workspace\\0_model\\越南夏普\\夏普模组\\正面/'
    publish = rootPath
    prefix = "model_module正_"  #model名称的前缀
    name = "模组正面线扫工位"
    #key = "矩形"
    key = "异形"
    
    if key == "矩形":
        #矩形
        dstProductsList=[
            #"12.0矩形2",   #不统一更新，产品结构特殊
                        "12.2矩形2", 
                        "16.3矩形3"
                        ]
        stepIdxListNot = [
                       212,  #AA下边
                       
                       ]
        #编辑参数####################################################
        srcProduct="16.3矩形3"
        commitInfo = "调整产品边卡尺定位， 添加modelinfostep"
        #编辑参数####################################################
    elif key == "异形":
        #异形
        dstProductsList = [
            #3
            "12.2异形3",
            "16.3异形3"
        ]
        stepIdxListNot = [
                       287,  #AA油墨交界定位，AA偏移量
                   
                       ]
        #编辑参数####################################################
        srcProduct="12.2异形3"
        commitInfo = "降低AA暗缺陷提取10"
        #编辑参数####################################################
    else :
        exit(-1)
    print(name)
    print("发布：",publish)
    print("commitInfo: ", commitInfo)
    inputStr = input("当前源model："+srcProduct+"\n是否确认更新(y/n): ")
    print(inputStr)
    if inputStr != 'y':
        print("指令错误: " + inputStr)
        exit(0)

    commitInfo = commitInfo+", 同步model-"+srcProduct

    dstModelPathList = []
    for dstProducts in dstProductsList:
        dstModelPathList.append(rootPath+dstProducts+"/"+prefix+dstProducts+"/")
    

    srcProductPath=rootPath+srcProduct+"/"+prefix+srcProduct+"/"
    demo(publish=publish,srcProductPath=srcProductPath, 
        dstModelPathList=dstModelPathList,commitInfo=commitInfo,stepIdxListNot=stepIdxListNot)
    


if __name__ == "__main__":  
    currentTime = datetime.datetime.now().strftime('%Y-%m-%d  %H:%M:%S')
    currentDate = datetime.datetime.now().strftime('%Y-%m-%d')

    run()


    exit(0)


    
